package com.ivncorp.evnproject.data;

import java.util.Map;

import com.ivncorp.evnproject.model.ObjectCot;
import com.ivncorp.evnproject.model.ObjectTram;
import com.ivncorp.evnproject.model.ObjectTuTT;

import android.database.sqlite.SQLiteDatabase;
import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.AbstractDaoSession;
import de.greenrobot.dao.identityscope.IdentityScopeType;
import de.greenrobot.dao.internal.DaoConfig;

public class DaoSession extends AbstractDaoSession {

	private TuTTDao tuTTDao;
	private TramDao tramDao;
	private CotDao cotDao;
	private DaoConfig TuTTDaoConfig;
	private DaoConfig TramDaoConfig;
	private DaoConfig CotDaoConfig;

	public DaoSession(SQLiteDatabase db, IdentityScopeType type,
			Map<Class<? extends AbstractDao<?, ?>>, DaoConfig> daoConfigMap) {
		super(db);

		TuTTDaoConfig = daoConfigMap.get(TuTTDao.class).clone();
		TuTTDaoConfig.initIdentityScope(type);
		TramDaoConfig = daoConfigMap.get(TramDao.class).clone();
		TramDaoConfig.initIdentityScope(type);
		CotDaoConfig = daoConfigMap.get(CotDao.class).clone();
		CotDaoConfig.initIdentityScope(type);

		tuTTDao = new TuTTDao(TuTTDaoConfig, this);
		tramDao = new TramDao(TramDaoConfig, this);
		cotDao = new CotDao(CotDaoConfig, this);

		registerDao(ObjectTuTT.class, tuTTDao);
		registerDao(ObjectTram.class, tramDao);
		registerDao(ObjectCot.class, cotDao);
	}

	public void clear() {
		TuTTDaoConfig.getIdentityScope().clear();
		TramDaoConfig.getIdentityScope().clear();
		CotDaoConfig.getIdentityScope().clear();
	}

	public TuTTDao getTuTTDao() {
		return tuTTDao;
	}

	public TramDao getTramDao() {
		return tramDao;
	}

	public CotDao getCotDao() {
		return cotDao;
	}

}
